
<template>
<div  class="app-container">
  <el-button type="info">excel模板说明</el-button>
         <el-button type="primary" plain>
            <a :href="BASE_URL+'/centos/课程分类模板.xls'">↓点击下载模板</a>
         </el-button><br><br><br><br>
        <el-upload
  class="upload-demo"
  ref="upload"
  :action="BASE_URL+'/user/excel'"
  :on-preview="handlePreview"
  :on-remove="handleRemove"
  :headers="tokens"
  :file-list="fileList"
  :auto-upload="false"
  name="file"
  >
  <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
  <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button>
     </el-upload>
</div>
</template>
<script>
import {getToken} from "@/utils/auth";

export default {
  data() {
    return {
      tokens:{
        "token": getToken()
      },
        BASE_URL:process.env.VUE_APP_BASE_API,
       fileList:[]
      };
  },
  methods: {
    submitUpload() {
      this.$refs.upload.submit();
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    }
  }
}
</script>
<style scoped lang="scss">

</style>
